#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

multiset <int> s1, s2;

int main(){
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, cnt1 = 0, cnt2 = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        s1.insert(a);
        if (a == 1) cnt1++;
        else if (a == 2) cnt2++;
    }
    if (cnt1 + cnt2 == n){
        cout << n - min(cnt1, cnt2);
        return 0;
    }
    int p = 0;
    while (!s1.empty()){
        if (s2.empty()){
            auto it = upper_bound(s1.begin(), s1.end(), *s1.begin());
            if (it == s1.end()) break;
            s1.erase(s1.begin());
            s2.insert(*it);
            s1.erase(it);
        } else {
            if (*s1.begin() < *s2.begin()){
                auto it = upper_bound(s1.begin(), s1.end(), *s1.begin());
                if (it == s1.end()) break;
                s1.erase(s1.begin());
                s2.insert(*it);
                s1.erase(it);
            } else {
                auto it = upper_bound(s1.begin(), s1.end(), *s2.begin());
                if (it == s1.end()) break;
                s2.erase(s2.begin());
                s2.insert(*s1.begin());
                s1.erase(s1.begin());
            }
        }
    }
    cout << s2.size() + s1.size();
    return 0;
}
